import { ref } from "vue";
import IPC from "../background/ipc";

export default function useColumnRepositories(linkId) {
  const columnList = ref([]);

  const getColumnList = async (tableId) => {
    //console.log("linkId:" + linkId + "   tableId:" + tableId);
    let result = await IPC.invoke("mysql.columns", {
      linkId: linkId,
      tableId: tableId,
    });
    if (result.code == 0) {
      columnList.value = result.data;
    } else {
      columnList.value = [];
    }
  };

  return {
    columnList,
    getColumnList,
  };
}
